package com.group.www.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.group.www.dao.impl.GoodsInfoDao;
import com.group.www.interfaces.GoodsInfoServiceI;
import com.group.www.pojo.GoodsInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@com.alibaba.dubbo.config.annotation.Service
@Service
public class GoodsInfoServiceImp implements GoodsInfoServiceI{
    @Autowired
    private GoodsInfoDao dao;
    @Override
    public boolean add(GoodsInfo entity) {
        return dao.add(entity);
    }

    @Override
    public boolean update(GoodsInfo entity) {
        return dao.update(entity);
    }

    @Override
    public boolean delete(GoodsInfo entity) {
        String id=entity.getGoodsid().toString();
        return dao.delete(id,-1+"");
    }

    @Override
    public boolean deleteMany(String ids) {
        /**方便级联删除**/
        String categoryids=ids.split("~")[1];
        return dao.delete(ids,categoryids);
    }

    @Override
    public PageInfo<GoodsInfo> queryAll(int brandid, int pageIndex, int pageSize, Object names, Object types) {
        /**分页**/
        PageHelper.startPage(pageIndex,pageSize);
        List<GoodsInfo> list= dao.queryAll(brandid+"",names+"",types+"");
        PageInfo<GoodsInfo> page=new PageInfo<>(list);
        return page;
    }

    @Override
    public GoodsInfo queryById(int id) {
        return dao.queryById(id);
    }

    @Override
    public boolean updateSaleById(int id, int issale) {
        return dao.updateSaleById(id,issale);
    }

    /********/
    @Override
    public List<GoodsInfo> query() {
        return  dao.query();
    }
}
